package manager;

import entity.menu.*;
import org.json.JSONObject;
import service.WxServiceImpl;
import util.Request;

import java.io.InputStream;
import java.util.Map;

public class CreateMenu {
    static InputStream in= CreateMenu.class.getClassLoader().getResourceAsStream("wx-config.xml");
    static Map<String,String> Xmlmap= WxServiceImpl.parseRequest(in);
    private static final String MENU_URL=Xmlmap.get("menuUrl");
    public static void main(String[] args) {
        Button button=new Button();
//        button.getButton().add(new ViewButton("授权登录", Authorize.getAuthorizeUrl()));
//        button.getButton().add(new ViewButton("个人简历", "http://avatar-blog-golxen.oss-cn-shenzhen.aliyuncs.com/resume/resume"));
//        button.getButton().add(new ViewButton("个人博客","http://blog.golxen.cn"));
        button.getButton().add(new MiniprogramButton("门店助手", "https://rsms.golxen.com","wx60d7691f0bf92f27","pages/init"));
        SubButton sb=new SubButton("菜单");
        sb.getSub_button().add(new ClickButton("啥也不是","31"));
        sb.getSub_button().add(new ViewButton("Golxen博客","https://blog.golxen.com"));
        sb.getSub_button().add(new ClickButton("AI绘图","33"));
        button.getButton().add(sb);
        JSONObject jsonObject=new JSONObject(button);
        String url=MENU_URL.replace("ACCESS_TOKEN", WxServiceImpl.getAccessToken());
        System.out.println(Request.sendPost(url,jsonObject.toString()));


    }
}
